def show_over_weight(weights, average_weight):
    """
    打印超过平均体重的体重
    :param weights: 体重数组
    :param average_weight: 平均体重
    :return: 打印超出的体重
    """
    print('超出平均体重的有：', end='')
    for i in weights:
        if i > average_weight:
            print('{}'.format(i), end=', ')


def average_weights(weights):
    """
    计算平均体重
    :param weights: 体重数组
    :return: 平均体重
    """
    weights_sum = 0
    for i in weights:
        weights_sum = weights_sum + i
    average_weight = weights_sum / len(weights)
    return average_weight


def get_weights():
    """
    获取体重
    :return: 体重数组
    """
    weights = []
    i = 1
    while True:
        try:
            weight = float(input('请输入第 %2d 位学生的体重（输入“0”将退出输入）：' % i))
        except ValueError:
            print('输入错误！请输入数字！')
        if weight != 0:
            weights.append(weight)
            i += 1
        else:
            break
    return weights


def main():
    weights = get_weights()
    average_weight = average_weights(weights)
    show_over_weight(weights, average_weight)


main()
